package com.wsc.wisdomchina.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wsc.wisdomchina.R;
import com.wsc.wisdomchina.Tools.Tools;
import com.wsc.wisdomchina.javaBean.QiYeFaBuListBean;

import java.util.List;

/**
 * 我的发布 企业发布适配器
 * Created by ${wangtao} on 2017/3/12.
 */

public class WDFB_QYFB_Adapter extends BaseAdapter {

    private Context context;
    private List<QiYeFaBuListBean> messageBeen;

    public WDFB_QYFB_Adapter(Context context, List<QiYeFaBuListBean> messageBeen) {
        this.context = context;
        this.messageBeen = messageBeen;
    }


    @Override
    public int getCount() {
        return messageBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return messageBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        View view = convertView;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_wdfb_lyfb, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        QiYeFaBuListBean qiYeFaBuListBean=messageBeen.get(position);

        holder.item_wdfb_lyfb_title.setText(qiYeFaBuListBean.getTitle());
        holder.item_wdfb_lyfb_address.setText(qiYeFaBuListBean.getAddr());
        holder.item_wdfb_lyfb_phone.setText(qiYeFaBuListBean.getStreetName());
        holder.item_wdfb_lyfb_time.setText(Tools.formatDateTimeMMDD(Tools.formatData(qiYeFaBuListBean.getCreateDate())));
        Glide.with(context).load(qiYeFaBuListBean.getGuideImg())
                .into(holder.item_wdfb_lyfb_image);
        if (qiYeFaBuListBean.getState() == 0) {
            holder.item_wdfb_lyfb_slove.setText("审核中");
            holder.item_wdfb_lyfb_slove.setTextColor(Color.parseColor("#29D7F2"));
        } else if (qiYeFaBuListBean.getState() == 1) {
            holder.item_wdfb_lyfb_slove.setText("发布成功");
            holder.item_wdfb_lyfb_slove.setTextColor(Color.parseColor("#15CD1F"));
        } else if (qiYeFaBuListBean.getState() == 2) {
            holder.item_wdfb_lyfb_slove.setText("被拒绝");
            holder.item_wdfb_lyfb_slove.setTextColor(Color.parseColor("#FC5812"));
        }
        return view;
    }


    public class ViewHolder {
        private ImageView item_wdfb_lyfb_image;//容器
        private TextView item_wdfb_lyfb_title;//标题
        private TextView item_wdfb_lyfb_address;//图标
        private TextView item_wdfb_lyfb_phone;//网页
        private TextView item_wdfb_lyfb_slove;
        private TextView item_wdfb_lyfb_time;

        public ViewHolder(View view) {
            item_wdfb_lyfb_image = (ImageView) view.findViewById(R.id.item_wdfb_lyfb_image);//图片
            item_wdfb_lyfb_title = (TextView) view.findViewById(R.id.item_wdfb_lyfb_title);//标题
            item_wdfb_lyfb_address = (TextView) view.findViewById(R.id.item_wdfb_lyfb_address);//地址
            item_wdfb_lyfb_phone = (TextView) view.findViewById(R.id.item_wdfb_lyfb_phone);//电话
            item_wdfb_lyfb_slove = (TextView) view.findViewById(R.id.item_wdfb_lyfb_slove);//是否通过
            item_wdfb_lyfb_time=(TextView) view.findViewById(R.id.item_wdfb_lyfb_time);

        }
    }


}
